home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 March / Macworld (1998-03) (Disk 1).dmg / Shareware World / Utilities / Text Processing / Alpha / Tcl / Modes / igorMode.tcl < prev    next >
Encoding:
Text File  |  1997-10-08  |  2.1 KB  |  89 lines  |  [TEXT/ALFA]

  1. # nowrap
  2.  
  3. alpha::mode Igor 1.0 igorMenu { *.igor } {igorMenu} {
  4.     set igorMenu "•284"
  5.     addMenu igorMenu
  6. }
  7.  
  8. proc igorMenu {} {}
  9.  
  10. set igorSig IGR0
  11.  
  12. menu -n $igorMenu -p igorMenuProc {
  13.     "/S<U<OswitchToIgor"
  14.     "(-"
  15.     "/K<U<OopenFileInIgor"
  16.     "/K<U<O<BswitchFileToIgor"
  17. }
  18.  
  19. proc igorMenuProc {menu item} {
  20.     global igorSig
  21.     switch $item {
  22.         switchToIgor {app::launchFore $igorSig}
  23.         openFileInIgor {
  24.             openAndSendFile $igorSig
  25.         }
  26.         switchFileToIgor {
  27.             openAndSendFile $igorSig
  28.             killWindow
  29.         }
  30.     }
  31. }
  32.  
  33. newPref v leftFillColumn {3} Igor
  34. newPref v prefixString {//} Igor
  35. newPref f wordWrap {0} Igor
  36. newPref v funcExpr {^[ \t]*([pP]roc.+$|[mM]acro.+$|[fF]unction.+$)} Igor
  37. newPref v parseExpr {\b([_:\w]+)\s*\(} Igor
  38. newPref v wordBreak {[_\w]+} Igor
  39. newPref v wordBreakPreface {[^_\w]} Igor
  40. newPref f electricTab {1} Igor
  41. newPref f autoMark 0 Igor
  42. newPref v stringColor green Igor
  43. newPref v commentColor red Igor
  44. newPref v funcColor yellow Igor
  45. newPref v keywordColor blue Igor
  46.  
  47. set igorCommentRegexp    {(//|[^%]\|)}
  48. set igorPreRegexp        {^\#[\t ]*[a-z]*}
  49. set    igorKeyWords    {
  50.     break for if endif do while continue
  51.     return else end variable string wave NVAR SVAR
  52.     function proc macro
  53. }
  54.  
  55. regModeKeywords -e {//} -c red -f yellow -k blue -s green Igor $igorKeyWords
  56.  
  57. unset igorKeyWords
  58.  
  59. proc Igor::MarkFile {} {
  60.     global IgormodeVars
  61.     set pos 0
  62.  
  63.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 $IgormodeVars(funcExpr) $pos} res]} {
  64.         set start [lindex $res 0]
  65.         set end [expr [lindex $res 1] + 1]
  66.         set text [getText $start $end]
  67.         set inds($text) "$start [expr $start + [string length $text]]"
  68.         set pos $end
  69.     }
  70.  
  71.     set pos 0
  72.     set markExpr {(^[ \t]*[Mm]enu.*$|===[^=]+===\s*$)}
  73.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 "$markExpr" $pos} res]} {
  74.         set start [lindex $res 0]
  75.         set end [expr [lindex $res 1] -1]
  76.         set text [string trimright [getText $start $end] ]
  77.         set inds($text) "$start [expr $start + [string length $text]]"
  78.         set pos $end
  79.     }
  80.     if {[info exists inds]} {
  81.         foreach f [array names inds] {
  82.             set res $inds($f)
  83.             setNamedMark $f [lineStart [lindex $res 0]] [lindex $res 0] [lindex $res 1]
  84.         }
  85.     }
  86.     namedMarkProc {namedMarks} {sortByPosition}
  87. }
  88.  
  89.